/**
 * Created by Administrator on 2017/11/16 0016.
 */
var common = require('../../common');
var pool = require('../index');
var mysql = require('mysql');
var YjxBaseModel = require('./YjxBaseModel');
var CONFIG = require('../../config');


var YjxSearchTagModel = function (obj) {
    YjxBaseModel.call(this,obj);
};

YjxSearchTagModel.prototype = new YjxBaseModel();

// 取得表名
YjxSearchTagModel.prototype.getTableName = function(){
    return 'yjx_search_tag';
};
// 取得查询语句中where 后面匹配主键的条件（需要各派生类进行重载）
YjxSearchTagModel.prototype.getWhereConditionOfKeyEqual = function(){
    return 'tag_id='+this.tag_id;
};


/**
 * 搜索热词
 *
 * @param callback 回调
 *          err 错误
 *          data 返回的数据
 *
 *
 * */
YjxSearchTagModel.prototype.getHotSearch_v1_0 = function(callback){
    pool.pool.getConnection(function(getConnectErr,connection){
        if(getConnectErr){
            console.log('YjxSearchTagModel.getHotSearch_v1_0 Err: ' + getConnectErr)
            return callback(getConnectErr,null);
        }
        var sql = 'SELECT name from yjx.yjx_search_tag search WHERE del_flg =0 ORDER BY search.order'
        connection.query(sql,function(error,results){
            connection.release();
            if(error){
                console.log('YjxSearchTagModel.getHotSearch_v1_0 Err: ' + error);
                return callback(error, null);
            }
            return callback(null,results)
        })
    })
};
module.exports = YjxSearchTagModel;